test: Isolate network calls in RelationTests and UserTests#428
Conversation
The RelationTests and UserTests.TestLogOut tests made real network requests
that failed on the Windows CI runner with a TLS decryption error, which has
kept master's CI red.
Root cause: `new ServerConnectionData { Test = true }` with no ServerURI
defaults to the dead https://api.parse.com server, and these tests were not
fully isolated from the network:
- RelationTests.SetUp built a mock service hub but never passed it to the
ParseClient, so `user.SignUpAsync()` in the test arrange hit the network.
Wire the mock hub into the client and make TearDown null-safe for the
resulting OrchestrationServiceHub.
- UserTests.TestLogOut bound the user to the un-mocked hub, so session
revocation during logout went to the network. Bind the user to the mocked
client, and replace the invalid `.CallBase()` on the interface mock with
`Task.CompletedTask`.
All 234 tests now pass.
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
Problem
masterCI has been failing on every push since ~January 2026. All PRs (including Dependabot bumps such as #425) inherit the failure, so nothing can go green. Exactly 6 tests fail on the Windows runner:RelationTests:AddRelationToUserAsync_ThrowsException_WhenRelationFieldIsNull,UpdateUserRelationAsync_ThrowsException_WhenRelationFieldIsNull,DeleteUserRelationAsync_ThrowsException_WhenRelationFieldIsNull,GetUserRelationsAsync_ThrowsException_WhenRelationFieldIsNull,AddRelationToUserAsync_ThrowsException_WhenRelatedObjectIsUnsavedUserTests.TestLogOutAll fail with the same Windows Schannel error:
Root cause
These tests make real network requests that should have been mocked.
new ServerConnectionData { Test = true }with noServerURIdefaults to the long-deadhttps://api.parse.com/1/server (ParseClient.cs). On the Windows runner the TLS handshake against that endpoint fails; on other platforms it happens not to throw, which is why the failure was invisible locally.Two separate mocking gaps let the calls escape:
RelationTests.SetUpcreated aMutableServiceHubwith mocked controllers but never passed it to theParseClient, soawait user.SignUpAsync()in the test arrange hit the real network before the assertion was ever reached. (The*_WhenUserIsNullvariants pass because they throwArgumentNullExceptionbefore any network call.)UserTests.TestLogOutbound theuserto the un-mocked SetUp client, so session revocation during logout (ParseUser.LogOutAsync→Services.RevokeSessionAsync) went to the network. It also used.CallBase()on an interface mock, which throws once the network no longer masks it.Fix (test-only)
RelationTests.SetUp: wire the mock hub into the client (new ParseClient(connectionData, hub)) and makeTearDownnull-safe for the resultingOrchestrationServiceHub.TestLogOut:user.Bind(client)so session revocation uses the mockedSessionController, and replace the invalid.CallBase()with.Returns(Task.CompletedTask).No SDK/product code is changed.
Verification
Each fix was verified by first reproducing the failure deterministically (pointing the test client at an unreachable URI →
Connection refused, mirroring the CI failure), then confirming the tests pass with that unreachable URI still set — proving the tests no longer depend on the network. Full suite:(Was
Failed: 6, Passed: 228.)